﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Inaction.Security
{
    [Serializable]
    public sealed class DefaultPrincipal : Principal
    {
        public DefaultPrincipal(string userNumber, string password)
        {
            Identity = new DefaultIdentity(userNumber, password);
            if(AppConfig.Instance.RunLocation != RunLocation.Server)
            {

            }
        }
        public DefaultPrincipal(Inaction.Security.IIdentity identity)
        {
            this.Identity = identity;
        }
        public override bool IsInRole(string role)
        {
            return false;
        }
        public override IEnumerable<IRole> GetOwnedRoles()
        {
            return null;
        }
       
        #region DefaultIdentity
        [Serializable]
        class DefaultIdentity : Security.IIdentity
        {
            public DefaultIdentity(string userNumber, string password)
            {
                UserNumber = userNumber;
                Token = Security.DEncrypt.MakeHashSalt(password);
            }

            public string Name { get { return string.Empty; } }

            public bool IsAdmin { get { return false; } }

            public string UserNumber { get; private set; }

            public Guid? Id { get; private set; }

            public byte[] Token
            {
                get;
                private set;
            }

            public string AuthenticationType
            {
                get { return string.Empty; }
            }

            public bool IsAuthenticated
            {
                get { return false; }
            }


            public Guid? DepartmentId
            {
                get { return null; }
            }
        }
        #endregion
    }
}
